<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/pages/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广东工业大学招生办后台管理</title>
<script type="text/javascript" src="../js/jquery.js"></script>

<style>
.tips{
	display:none;
	color:red;
	font-size: 12px;
	width:110px;
}
.in{
	width:100%;
}
textarea{
	width:100%;
	height:100px;
}
form{
	margin:0 auto;
	width:450px;
}
.tableHead{
	width:100px;
}
.checkboxLabel{
	
	display: block;
	float: left;
	width: 90%;
	height:20px;
}
input{
	width:10%;
	margin: 0;
	padding:0;
	float: left;
	height:20px;
}

</style>
</head>

<body>
	<form action="employee-admin!save.action" method="post" name="form" id="employee-form" >
	<input type="hidden" name="id" value="${id }" />
	<input type="hidden" name="oldloginname" id="oldloginname" value="${loginName }" />
	
	<table>
		<tr>
			<th colspan="3"><s:if test="id == null" >新增</s:if><s:else>修改</s:else>用户</th>
		</tr>
		<tr>
			<td class="tableHead">帐号：</td>
			<td style="width:225px"><input type="text" name="loginName" value="${loginName }"  <s:if test="id != null" >readonly="readonly" </s:if>  id="user" maxlength="26" class="in" /></td>
			<td class="tips" id="userTips" >请输入帐号！</td>
		</tr>
		<tr>
			<td class="tableHead">姓名：</td>
			<td style="width:225px"><input type="text" name="name" value="${name }" id="name" maxlength="26" class="in" /></td>
			<td class="tips" id="nameTips">请输入姓名！</td>
		</tr>
		<tr>
			<td class="tableHead">角色信息：</td>
			<td style="width:225px">
				<s:checkboxlist name="checkedRoleIds" list="allRoleList" listKey="id" listValue="name" />
			</td>
			<td class="tips" id="infoTips">请选择角色信息！</td>
		</tr>
		<tr>
			<td class="tableHead">联系方式：</td>
			<td style="width:225px"><input type="text" name="contact" value="${contact }" id="tel" maxlength="26" class="in" /></td>
			<td class="tips" id="telTips">请输入联系方式！</td>
		</tr>
		<tr>
			<td class="tableHead">描述：</td>
			<td style="width:225px"><textarea name="summary"  id="describe"  >${summary }</textarea></td>
			<td class="tips" id="describeTips">请输入描述！</td>
		</tr>
		<tr>
			<td class="tableHead"></td>
			<td><input type="button" onclick="check()" value="提交" style="width:15%;"/><input type="reset" value="重置" style="width:15%;"/></td>
			<td style="width:110px"></td>
		</tr>
	</table>
	</form>
</body>
<script  type="text/javascript" >
	function check(){
		var user = document.getElementById("user");
		var name = document.getElementById("name");
		

		var tel = document.getElementById("tel");
		var describe = document.getElementById("describe");
		var flag = 1;
		
		if(user.value == ""){
			document.getElementById("userTips").style.display="inline";
			flag = 0;
		}
	
		if(name.value == ""){
			document.getElementById("nameTips").style.display="inline";
			flag = 0;
		}
		
		
		
		/*if(info.value == ""){
			document.getElementById("infoTips").style.display="inline";
			flag = 0;
		}*/
		if(tel.value == ""){
			document.getElementById("telTips").style.display="inline";
			flag = 0;
		}
		if(describe.value == ""){
			document.getElementById("describeTips").style.display="inline";
			flag = 0;
		}
		if(flag == 0){
			return;
		}
		$.post("<s:property value="ctx"/>/admin/employee-admin!checkLoginName.action", "loginName="+$('#user').val()+"&&oldLoginName="+$('#oldloginname').val() ,function callback(text){
             		if(text == "true"){
             			$("#employee-form").submit();
             		}else{
             			alert("用户名已存在");
             			flag=0;
             			return;
             		}
             		
         });
	}

/* 	var checkbox = $(".tdLabel").siblings().find("label");
	checkbox.each(function(){
	html = $(this).html();
    alert($(this).html());
    $(this).html() = html + "<br/>";
    }); */
</script>
</html>



